//Monday, December 14 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class RandomSort
{
public:
	double getExpected(vector <int> permutation)
	{
		int count = 0;
		double ret = 0.0;
		bool flag = true;
		for(int i=0; i+1<permutation.size(); i++)
		{
			if(permutation[i+1] < permutation[i])
			{
				flag = false;
				break;
			}
		}
		if(v.count(permutation) > 0)
			return v[permutation];
		if(flag) return 0.0;
		for(int i=0; i<permutation.size(); i++)
		{
			for(int j=i+1; j<permutation.size(); j++)
			{
				if(permutation[j] < permutation[i])
				{
					swap(permutation[i], permutation[j]);
					ret += getExpected(permutation);
					count ++;
					swap(permutation[j], permutation[i]);
				}
			}
		}
		cout << count << endl;
		ret /= 1.0*count;
		ret += 1.0;
		return v[permutation] = ret;
	}
	map<vector<int>, double> v;
};
